//
//  Person.m
//  03-23-PM-单例
//
//  Created by student on 16/3/23.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "Person.h"

//方式1:GCD

@implementation Person

static Person *instance = nil;
+(instancetype)allocWithZone:(struct _NSZone *)zone
{
    @synchronized(self) {
        if (instance==nil) {
            instance=[super allocWithZone:zone];
        }
    }
    
    return instance;
}
+(Person *)sharePerson
{
    @synchronized(self)
    {
        if (instance==nil) {
            instance=[[Person alloc]init];
        }
    }
   
    return instance;
}
- (id)copyWithZone:(nullable NSZone *)zone
{
    return instance;
}

@end
